﻿using System;
using ReadyApps.Wiki.ViewModels;
using System.Net;

namespace ReadyApps.Wiki
{
    /// <summary>
    /// The arguments used by the title setting event.
    /// </summary>
    public class TitleSetEventArgs : EventArgs
    {
        #region Properties

        /// <summary>
        /// Gets the page title to set.
        /// </summary>
        public string Title { get; private set; }

        #endregion

        #region Constructor

        /// <summary>
        /// Creates a new <see cref="TitleSetEventArgs"/> object with the supplied title
        /// value.
        /// </summary>
        /// <param name="title">The page title to set.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="title"/> parameter
        /// was <c>null</c>.</exception>
        public TitleSetEventArgs(string title)
        {
            if (title == null)
            {
                throw new ArgumentNullException("title");
            }
            Title = title;
        }

        #endregion
    }

    class ViewRevisionEventArgs : EventArgs
    {
        #region Properties

        public int RevisionNumber { get; private set; }

        #endregion

        #region Constructor

        public ViewRevisionEventArgs(int revisionNumber)
        {
            RevisionNumber = revisionNumber;
        }

        #endregion
    }

    class SaveViewModelEventArgs : EventArgs
    {
        #region Properties

        public IWikiViewModel ViewModel { get; private set; }

        #endregion

        #region Constructor

        public SaveViewModelEventArgs(IWikiViewModel viewModel)
        {
            ViewModel = viewModel;
        }

        #endregion
    }

    class SavePageEventArgs : EventArgs
    {
        #region Properties

        public bool ExistingPage { get; private set; }

        public string PageName { get; private set; }

        public string PageTitle { get; private set; }

        public string RawContent { get; private set; }

        #endregion

        #region Constructors

        public SavePageEventArgs(string pageTitle, string rawContent)
        {
            ExistingPage = true;
            PageTitle = pageTitle;
            RawContent = rawContent;
        }

        public SavePageEventArgs(string pageName, string pageTitle, string rawContent)
            : this(pageTitle, rawContent)
        {
            ExistingPage = false;
            PageName = pageName;
        }

        #endregion
    }

    class CreateNewSiteEventArgs : EventArgs
    {
        #region Properties

        public bool SecurityEnabled { get; private set; }

        public string Creator { get; private set; }

        #endregion

        #region Constructor

        public CreateNewSiteEventArgs(bool securityEnabled, string creator)
        {
            SecurityEnabled = securityEnabled;
            Creator = creator;
        }

        #endregion
    }

    class WikiPageStatusEventArgs : EventArgs
    {
        #region Properties

        public HttpStatusCode StatusCode { get; private set; }

        #endregion

        #region Constructor

        public WikiPageStatusEventArgs(HttpStatusCode statusCode)
        {
            StatusCode = statusCode;
        }

        #endregion
    }

    class IncludeResourceEventArgs : EventArgs
    {
        #region Properties

        public string Resource { get; private set; }
        public IncludeType IncludeType { get; private set; }

        #endregion

        #region Constructor

        public IncludeResourceEventArgs(IncludeType includeType, string resource)
        {
            Resource = resource;
            IncludeType = includeType;
        }

        #endregion
    }

    class RedirectEventArgs : EventArgs
    {
        #region Properties

        public string RedirectUrl { get; private set; }

        #endregion

        #region Constructor

        public RedirectEventArgs(string redirectUrl)
        {
            RedirectUrl = redirectUrl;
        }

        #endregion
    }
}
